package com.mike.excel;

import java.util.List;

import com.excel.TableModel;
import com.excel.model.AttributeExcelModel;
import com.excel.model.TableExcelModel;
import com.excel.read.AllTable;
import com.excel.read.Config;
import com.excel.read.ExcelTable;
import com.excel.read.ExcelTableConfig;
/**
 * 用于测试
 * @author Administrator
 *
 */
public class TestTableConfig {
      public static ExcelTable process(ExcelTable aExcelTable) {
    	  TestExcelTable aTestExcelTable = new TestExcelTable();
    	TableExcelModel aTableExcelModel;
    	
  		// 二维表
  		aTableExcelModel = new TableExcelModel(aExcelTable.aTableModel,	2, 0, -2, 4);
  		TableModel aTableModel = aExcelTable.aTableModel;
  		aTableExcelModel.extract();
  		aExcelTable.aTableExcelModel = aTableExcelModel;
  		aExcelTable.aTableModel = aTableModel;		
  		aTestExcelTable.data = aTableExcelModel.getData();
  		// 属性表
  		String[] names = new String[] { "SQL" };
  		AttributeExcelModel aAttributeExcelModel = new AttributeExcelModel(
  				aTableModel, names);
  		aAttributeExcelModel.extract();
  		aTestExcelTable.setSQL(aAttributeExcelModel.getValue("SQL"));
  		aTestExcelTable.setName(aAttributeExcelModel.getValue("名称"));
  		return aTestExcelTable;
      }
      
      
	public static ExcelTable readFormatTable() {
		
		AllTable allTable = Config.allTable;
		 List<ExcelTable>  aExcelTables = allTable.getExcelTables();
		 for(ExcelTable aExcelTable : aExcelTables) {
			 TestExcelTable aTestExcelTable = (TestExcelTable) process(aExcelTable);
			 
			
		 }
		
		
		return null;
		
	}

public static void main(String args[]) {
		//缓存
		ExcelTableConfig gridSearchConfig = new ExcelTableConfig();
		gridSearchConfig.tableConfig("d:\\x.xls");
		//读取表格
		TestTableConfig.readFormatTable();
//		String data = "<table><tr><td>ds</td><td colspan=2>ds</td></tr><tr><td>ds</td><td>ds</td><td>ds</td></tr><table>";
//		MExcelWriter excelWrite = new ComplexTableExcelWriter("", data, "");
//		excelWrite.setTableDisplayName("ds");
//		excelWrite.setSheetName("查询");
//		try {
//			OutputStream os = new FileOutputStream("d:\\x.xls");
//			excelWrite.init(os);
//			excelWrite.writeExcel();
//			excelWrite.exit();
//
//		} catch (WriteException e) {
//			e.printStackTrace();
//		} catch (IOException e) {
//			e.printStackTrace();
//		} catch (SQLException e) {
//			// TODO Auto-generated catch block
//			e.printStackTrace();
//		}

	}

	
	
}
